<template>
	<div class="about">
		<h1>This is an express API</h1>
		<div class="demo-input-suffix">
			<el-button @click="exApiGet()">getAll</el-button>
			<br />
			cateid:
			<el-input v-model="cateid" placeholder="cateid" />

			<el-button type="danger" @click="exApiGetexCateid()">getCateidAll</el-button>
			<br />
			title:
			<el-input v-model="form.title" placeholder="title" />
			author:
			<el-input v-model="form.author" placeholder="author" />
			pageviews:
			<el-input v-model="form.pageviews" placeholder="pageviews" />
			status:
			<el-input v-model="form.status" placeholder="status" />
			<el-button type="success" @click="exApiAdd()">exApiAdd</el-button>
			<br />
			id:
			<el-input v-model="id" placeholder="id" />
			<el-button type="warning" @click="exApidel()">exApidel硬删除</el-button>
			<br />
			status:
			<el-radio-group v-model="radio" size="medium">
				<el-radio-button label="0">已删除</el-radio-button>
				<el-radio-button label="1">已发布</el-radio-button>
				<el-radio-button label="2">已出售</el-radio-button>
				<el-radio-button label="3">已收货</el-radio-button>
			</el-radio-group>
			<br />
			<el-button type="primary" @click="exApiStatusdel()">exApidel软删除</el-button>
			<br />
			<br />
			<el-button type="primary" @click="exApiupdate()">exApiupdate</el-button>
			<br />
		</div>
	</div>
</template>
<script>
import { exApiGet, getCateidAll } from '../api/index';
import { exApidel, exApiStatusdel } from '../api/delete';
import { exApiAdd } from '../api/insert';
import { getupdate } from '../api/update';

export default {
	data() {
		return {
			id: '',
			cateid: '',
			studentAll: '',
			studentid: '',
			exApiAll: '',
			radio: 1,
			form: {
				title: '',
				author: '',
				pageviews: '',
				status: ''
			},
			form_insert: {
				name: '',
				age: ''
			},
			form_upload: {
				id: '',
				name: '',
				age: ''
			}
		};
	},
	methods: {
		exApiGet() {
			exApiGet({})
				.then(res => {
					this.exApiAll = res;
					console.log(this.exApiAll);
				})
				.catch(err => {
					console.log(err);
				});
		},
		exApiGetexCateid() {
			let obj = {};
			obj.id = this.cateid;
			console.log(obj);
			getCateidAll(obj)
				.then(res => {
					this.exApiAll = res;
					console.log(this.exApiAll);
				})
				.catch(err => {
					console.log(err);
				});
		},
		exApiAdd() {
			let obj = this.form;
			console.log(obj);
			exApiAdd(obj)
				.then(res => {
					console.log(res);
				})
				.catch(err => {
					console.log(err);
				});
		},
		exApidel() {
			let obj = {};
			obj.id = this.id;
			console.log(obj);
			exApidel(obj)
				.then(res => {
					console.log(res);
				})
				.catch(err => {
					console.log(err);
				});
		},
		exApiStatusdel() {
			let obj = this.form;
			obj.id = this.id;
			obj.status = this.radio;
			console.log(obj);
			exApiStatusdel(obj)
				.then(res => {
					console.log(res);
				})
				.catch(err => {
					console.log(err);
				});
		},
		exApiupdate() {
			let obj = this.form;
			obj.id = this.id;
			console.log(obj);
			getupdate(obj)
				.then(res => {
					console.log(res);
				})
				.catch(err => {
					console.log(err);
				});
		},
	},
	mounted() {}
};
</script>
